<?php
/**
 * 轻云网络验证系统
 * =======================================================
 * 版权所有(C) 2019-2039 daenx.cn，并保留所有权利。
 * 作者：Daen大恩
 * 作者QQ: 1330166565
 * 开发群：661059773
 * =======================================================
 */
    include 'farmwork.php';
	header("content-type:text/html;charset=utf-8");
	login();
	
	$action = $_GET['action'];
	$time=time();
	if($action=='do'){
		$cp = $_POST['cp'];
		$ms = $_POST['ms'];
		$nver = $_POST['nver'];
		$nkey = $_POST['nkey'];
		$url = $_POST['url'];
		$qz = $_POST['qz'];
		$qt = $_POST['qt'];
		$free = $_POST['free'];
		$jg1 = $_POST['jg1'];
		$jg2 = $_POST['jg2'];
		$jg3 = $_POST['jg3'];
		$jg4 = $_POST['jg4'];
		$jg5 = $_POST['jg5'];
		$jg6 = $_POST['jg6'];
				$xjjg1 = $_POST['xjjg1'];
				$xjjg2 = $_POST['xjjg2'];
				$xjjg3 = $_POST['xjjg3'];
				$xjjg4 = $_POST['xjjg4'];
				$xjjg5 = $_POST['xjjg5'];
				$xjjg6 = $_POST['xjjg6'];
		$kf = $_POST['kf'];
		$qd = $_POST['qd'];
		$qd_rmb = $_POST['qd_rmb'];
$alive = $_POST['alive'];
	    $sql="select * from products where cp='$cp'";
        $query=mysqli_query($con,$sql);
        $rows = mysqli_num_rows($query);
		if($rows > 0){
		   echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">产品信息已存在！</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'products-add.php' });  }});</script>");
		   $sql = "UPDATE `products` SET `time` = '$time' ;";
		   mysqli_query($con,$sql);
		}else{
		   $sql = "INSERT INTO `products` (`cp`, `ms`, `time`,`nver`,`nkey`,`url`,`qz`,`free`,`zt`,`qt`,`jg1`,`jg2`,`jg3`,`jg4`,`jg5`,`jg6`,`kf`,`qd`,`qd_rmb`,`xjjg1`,`xjjg2`,`xjjg3`,`xjjg4`,`xjjg5`,`xjjg6`,`alive`) VALUES ('$cp', '$ms', '$time','$nver','$nkey','$url','$qz','$free','1','$qt','$jg1','$jg2','$jg3','$jg4','$jg5','$jg6','$kf','$qd','$qd_rmb','$xjjg1','$xjjg2','$xjjg3','$xjjg4','$xjjg5','$xjjg6','$alive');";
	       mysqli_query($con,$sql);
		   $sql = "INSERT INTO `version` (`ver`, `ddata`, `dtime`, `dkey`, `cp`, `url`, `qz`) VALUES ('$nver', '第一个版本', '$time', '$nkey', '$cp', '$url', '$qz');";
	       mysqli_query($con,$sql);
		   //mysqli_close();
		   echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">添加成功！</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'products.php' });  }});</script>");
		   //die;
		}
	}

$li9='class="active"';
$li91='class="active"';
?>
<?php include 'header.php';?>
    <title>添加产品-<?php echo $title?></title>
<?php include 'list.php';?>
    <!--main content start-->
    <section id="main-content">
        <section class="wrapper">
<?php include 'overview.php';?>
            <div class="row">
                <div class="col-lg-12">
                    <!--work progress start-->
                    <section class="panel">
                        <div class="panel-body progress-panel">
                            <div class="task-progress">
                                <h1>添加新产品</h1>
                                <p>填写产品信息并保存.</p>
                            </div>
                        </div>
						<form action="products-add.php?action=do" method="post"  role="form">
                            <div class="form-group">
                                <label for="txtDomain">产品</label>
                                <input type="text" name="cp" class="form-control" placeholder="输入产品名称">
                            </div>
                            <div class="form-group">
                                <label for="txtDomain">公告   (请勿使用回车换行，推荐使用< br >)</label>
								<textarea class="form-control" name="ms" clos="100" rows="5"/></textarea>
                            </div>

									
							<div class="form-group">
                                <label for="txtDomain">版本</label>
                                <input type="text" name="nver" class="form-control" placeholder="请输入版本">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">存活时长</label>
                                <input type="text" name="alive" class="form-control" placeholder="上次在线小于多少秒则视为在线中">
                            </div>
							<div class="form-group">
							  <label>是否强制更新</label>
							  <select name="qz" class="form-control">
								<option value="0">否</option>
								<option value="1">是</option>
							  </select>
							</div>
							<div class="form-group">
							  <label>是否免费</label>
							  <select name="free" class="form-control">
							    <option value="1">是</option>
								<option value="0">否</option>
							  </select>
							</div>
							<div class="form-group">
							  <label>是否开放注册</label>
							  <select name="kf" class="form-control">
							    <option value="1">是</option>
								<option value="0">否</option>
							  </select>
							</div>
							<div class="form-group">
							  <label>是否开放签到</label>
							  <select name="qd" class="form-control">
							    <option value="1">是</option>
								<option value="0">否</option>
							  </select>
							</div>
							<div class="form-group">
                                <label for="txtDomain">签到奖励余额</label>
                                <input type="text" name="qd_rmb" class="form-control" placeholder="签到奖励余额">
                            </div>
							<div class="form-group">
							  <label>前台是否显示</label>
							  <select name="qt" class="form-control">
							    <option value="1">是</option>
								<option value="0">否</option>
							  </select>
							</div>
							<div class="form-group">
                                <label for="txtDomain">下载地址</label>
                                <input type="text" name="url" class="form-control" placeholder="http://开头">
                            </div>
							<div class="form-group">
                                <label for="txtDomain"><i class="fa fa-key"></i>最新KEY<input class="btn btn-primary btn-xs" type= "button" name= "Submit1 " value= "生成" onclick= "show()"></label>
                                <input type="text" name="nkey" id="syskey"  class="form-control" value='<?php echo $syskey?>'>
 					<script language=javascript> 
						function show() 
						{ 
						var str= "0123456789abcdefghijklmnopqrstuvwxyz" 
						var result= " " 
						for(var i=0;i <32;i++) 
						{ 
						var temp=Math.floor(Math.random()*36) 
						result+=str.charAt(temp) 
						} 
						hash = result.MD5();
						document.getElementById( "syskey").value=hash
						} 
					</script>
                            </div>
							
							<div class="form-group">
                                <label for="txtDomain">天卡原价</label>
                                <input type="text" name="jg1" class="form-control" placeholder="原价：各级代理购买会乘以代理的折扣价">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">周卡原价</label>
                                <input type="text" name="jg2" class="form-control" placeholder="原价：各级代理购买会乘以代理的折扣价">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">月卡原价</label>
                                <input type="text" name="jg3" class="form-control" placeholder="原价：各级代理购买会乘以代理的折扣价">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">季卡原价</label>
                                <input type="text" name="jg4" class="form-control" placeholder="原价：各级代理购买会乘以代理的折扣价">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">年卡原价</label>
                                <input type="text" name="jg5" class="form-control" placeholder="原价：各级代理购买会乘以代理的折扣价">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">永久原价</label>
                                <input type="text" name="jg6" class="form-control" placeholder="原价：各级代理购买会乘以代理的折扣价">
                            </div>
							
							
							<div class="form-group">
                                <label for="txtDomain">授权商->代理商</label>
                                <input type="text" name="xjjg1" class="form-control" placeholder="添加下级价格">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">总销商->授权商</label>
                                <input type="text" name="xjjg2" class="form-control" placeholder="添加下级价格">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">总销商->代理商</label>
                                <input type="text" name="xjjg3" class="form-control" placeholder="添加下级价格">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">超管->总销商</label>
                                <input type="text" name="xjjg4" class="form-control" placeholder="添加下级价格">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">超管->授权商</label>
                                <input type="text" name="xjjg5" class="form-control" placeholder="添加下级价格">
                            </div>
							<div class="form-group">
                                <label for="txtDomain">超管->代理商</label>
                                <input type="text" name="xjjg6" class="form-control" placeholder="添加下级价格">
                            </div>

			<div id="bottom" >
			  <button class="btn btn-info" type="submit" value="true" id="submit"/><strong>添加产品</strong></button>
            </div>
                        </form>
                    </section>
                    <!--work progress end-->
                </div>

        </section>
    </section>
    <!--main content end-->

<?php include 'footer.php';?>
